<?php
namespace App\Providers;

use Illuminate\Routing\Router;
use Arcanedev\LogViewer\LogViewerServiceProvider as ServiceProvider;

class LogViewerServiceProvider extends ServiceProvider
{
	
	/**
     * Boot the service provider.
     */
    public function boot()
    {
        $this->publishConfig();
        $this->publishViews();
        $this->publishTranslations();
        $this->app->register('Arcanedev\\LogViewer\\Providers\\RouteServiceProvider');
    }

	
	
    protected function loadViewsFrom($path, $namespace)
    {
        if (is_dir($appPath = $this->app->basePath().'/data/resources/views/vendor/'.$namespace)) {
            $this->app['view']->addNamespace($namespace, $appPath);
        }

        $this->app['view']->addNamespace($namespace, $path);
    }
	
	
	/**
     * Publish and load the views if $load argument is true.
     *
     * @param  bool  $load
     */
    protected function publishViews($load = true)
    {
        if (is_dir($path = ($this->getBasePath() . '/resources/views'))) {
            $this->publishes([
                $path => base_path("data/resources/views/vendor/{$this->package}"),
            ], 'views');

            if ($load) $this->loadViews();
        }
    }
	
    /**
     * Publish and load the translations if $load argument is true.
     *
     * @param  bool  $load
     */
    protected function publishTranslations($load = true)
    {
        if (is_dir($path = ($this->getBasePath() . '/resources/lang'))) {
            $this->publishes([
                $path => base_path("data/resources/lang/vendor/{$this->package}"),
            ], 'lang');

            if ($load) $this->loadTranslations();
        }
    }	
}
